package org.zad1;

import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;


public class Sbox {

	private List<Integer> sbox = Collections.emptyList();
	
	public Sbox()
	{
		sbox = new ArrayList<Integer>();
	}
	
	public void init(String path)
	{
		DataInputStream data = null;
		try {
			data = new DataInputStream(new FileInputStream(new File(path)));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		
		int value = 0;
		int count = 0;
		try {
			while((value = data.read()) != -1)
			{
				count++;
				if(count % 2 > 0)
					sbox.add(value);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}	
	}
	
	public void display()
	{
		for(Integer i : sbox)
		{
			System.out.println(i);
		}
	}
	
	public int size()
	{
		return sbox.size();
	}
	
	public int get(int index)
	{
		return sbox.get(index);
	}
}
